<template>
	<view>
		<navView navTitle="信息收集" titleColor="#fff" :isBack="true"></navView>
		<view class="container">
			<view class="form">
				<picker mode="selector" :range="statusList" range-key="name" @change="shichange">
					<view class="item">
						<view class="name">
							是否选择被分享人
						</view>
						<view class="right">
							<view v-if="status == 'yes'">是</view>
							<view v-if="status == ''">请选择</view>
							<view v-if="status == 'no'">否</view>
							<uni-icons class="icon" size="32rpx" color="#C3C3C3" type="right"></uni-icons>
						</view>
					</view>
				</picker>
			</view>
			<view class="form" v-if="status === 'no'">
				<picker mode="selector" :range="statusList" range-key="name" @change="shichange">
					<view class="item">
						<view class="name">
							公司名称
						</view>
						<view class="right">
							<view v-if="status == 'yes'">是</view>
							<view v-if="status == ''">请选择</view>
							<view v-if="status == 'no'">否</view>
							<uni-icons class="icon" size="32rpx" color="#C3C3C3" type="right"></uni-icons>
						</view>
					</view>
				</picker>
				<view class="item">
					<view class="name">
						负责人姓名
					</view>
					<input placeholder="请输入" />
				</view>
				<view class="item">
					<view class="name">
						联系电话
					</view>
					<input placeholder="请输入" />
				</view>
			</view>
			<view class="form" v-if="status === 'yes'">
				<view class="link-wrapper">
					<text>专属链接</text>
					<view class="copy" @click="copyLink">复制</view>
				</view>
				<text class="link">{{ shareLink }}</text>
			</view>
		</view>
		<button class="submit" @click="submit">提交</button>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				statusList: [{
					name: '是',
					value: 'yes'
				}, {
					name: '否',
					value: 'no'
				}],
				status: '', // yes 表示“是”，no 表示“否”
				shareLink: 'https://www.com/pins/3510938564',
			};
		},
		methods: {
			shichange(e) {
				console.log(e)
				this.status = this.statusList[e.detail.value].value
			},
			submit() {
				uni.showToast({
					title: `当前状态是：${this.status === 'yes' ? '是' : '否'}`,
					icon: 'none',
				});
			},
			copyLink() {
				uni.setClipboardData({
					data: this.shareLink,
					success: () => {
						uni.showToast({
							title: '链接已复制',
							icon: 'none',
						});
					},
				});
			},
		},
	};
</script>

<style lang="scss">
	.container {
		padding: 20rpx;
		background: #fff;
		height: 50vh;
		border-top-left-radius: 16rpx;
		border-top-right-radius: 16rpx;
	}

	.form {
		.item {
			display: flex;
			align-items: center;
			justify-content: space-between;
			padding: 40rpx 20rpx;
			border-bottom: 1rpx solid #ccc;

			.right {
				display: flex;
				align-items: center;

				.icon {
					margin-left: 10rpx;
				}

			}

			input {
				text-align: right;
			}
		}
	}

	.link-wrapper {
		display: flex;
		justify-content: space-between;
		align-items: center;
		padding: 40rpx 20rpx;
	}

	.link {
		margin-top: 10rpx;
		color: #333;
		padding: 40rpx 20rpx;
	}

	.copy {
		font-weight: 400;
		font-size: 32rpx;
		color: #1592E6;
	}

	.submit {
		background-color: #008EFF;
		color: white;
		width: 95%;
		border-radius: 40rpx;
		margin-top: 20rpx;
		position: fixed;
		bottom: 50rpx;
		left: 50%;
		transform: translate(-50%);
	}
</style>